﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FrasesSimpsonsMvc.Models;

namespace FrasesSimpsonsMvc.Controllers
{
    public class AdminController : BaseController
    {
        
        public ActionResult Begin()
        {
            return View();
        }

        [HttpPost]
        public ActionResult List()
        {
            var frases = from t in Context.Frases
                         select t;

            foreach (var frase in frases)
            {
                frase.LoadRelatedEntities();
                frase.CantidadHistoria = Context.FrasesHistoria.Where(h => h.FrasesId == frase.Id).Count();
            }

            return View(frases.ToList());
        }
    }
}
